package sf.event.model;


import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;

import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

@XmlRootElement(name = "events")
public class EventList
  implements Serializable, Iterable<Event>
{

  private static final long serialVersionUID = 3307560955920202673L;

  private final List<Event> events;

  public EventList()
  {
    events = new ArrayList<Event>();
  }

  public EventList(final Collection<Event> events)
  {
    this();
    if (events != null)
    {
      this.events.addAll(events);
    }
  }

  public boolean addAll(final Collection<? extends Event> c)
  {
    return events.addAll(c);
  }

  @XmlElement(name = "event")
  public List<Event> getEvents()
  {
    return events;
  }

  @Override
  public Iterator<Event> iterator()
  {
    return events.iterator();
  }

}
